package view.graph;

import datacontainer.ImmuTable;
import java.awt.Dimension;
import java.awt.Graphics2D;
import java.util.List;


/**
 * This superclass serves as the origin of a few fundamental
 * visualization methods, mainly for inputting the data,
 * setting up, and acutally displaying these charts.
 * @author Oren Bukspan, Kannan Raju
 */
public abstract class AbstractVisualization {

    /**
     * Takes in the data, received in the form of an ImmuTable, and stores it in
     * appropriate structures for each type of visualization.
     * 
     * @param data The ImmuTable from which the visualization will be derived,
     *        each
     *        column representing some series of data.
     */
    public abstract void inputData (ImmuTable data);

    /**
     * This function will conduct the actual drawing of the images/lines/bars,
     * etc.
     * on the graphs. There may be many helper methods, but paint will govern
     * the display
     * visualization illustration.
     * 
     * @param graphics The graphics/drawing tool to be used in drawing a
     *        visualization
     * @param dim The dimensions of the window (width, height)
     */
    public abstract void paintComponent (Graphics2D graphics, Dimension dim);

    /**
     * Sets up the foundations of the graph, at the very least coloring the
     * background
     * and writing in the Title. Purely graphics related.
     * 
     * @param graphics The graphics/drawing tool to be used in drawing a
     *        visualization
     * @param windowWidth The 'width' Dimension of the window. Can be changed by
     *        the user.
     * @param windowHeight The 'height' Dimension of the window. Can be changed
     *        by the
     *        user.
     */
    public abstract void setUpVisualisationBackground (Graphics2D graphics, int windowWidth,
                                                       int windowHeight);

    /**
     * Finds the Maximum Value in a particular Column. This will be used to
     * determine
     * the Height of a particular Visualization.
     * 
     * @param list The column which will be assessed to determine a maximum.
     * @return
     */
    public double getMaxInColumn (List<String> list) {
        double maxValue = 0;
        for (int q = 0; q < list.size(); q++) {
            Double elemInColumn = Double.parseDouble(list.get(q));
            if (maxValue < elemInColumn) {
                maxValue = elemInColumn;
            }
        }
        return maxValue;
    }

}
